#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

LL n,l,r;

int main() {
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	
	scanf("%lld%lld%lld",&n,&l,&r);
	
	LL x=l/n*n+n-1;
	
	if (x<=r) printf("%lld",n-1);
	else printf("%lld",r%n);
	return 0;
}
